package org.common.utils.rpc.entity;

/**
 * Rpc响应实体
 * @author zhouzhibing
 * @date 2025/11/15 19:25
 */
public class RpcResponse {
    /**
     * 这个响应，所对应的请求id。
     */
    private final long requestId;
    /**
     * 响应结果
     */
    private final Object result;
    /**
     * 错误异常信息
     */
    private final String error;
    /**
     * toString 字符串
     */
    private transient String toString;

    public RpcResponse(long requestId , Object result, String error) {
        this.requestId = requestId;
        this.result = result;
        this.error = error;
    }

    public long getRequestId() {
        return requestId;
    }

    public Object getResult() {
        return result;
    }

    public String getError() {
        return error;
    }

    @Override
    public String toString() {
        if(toString != null) {
            return toString;
        }

        return toString = "RpcResponse{" +
                "requestId=" + requestId +
                ", result=" + result +
                ", error='" + error + '\'' +
                '}';
    }
}
